package com.cloud.code.牛客网;

import java.util.Arrays;
import java.util.Scanner;

public class Test54 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){

            String line = scanner.nextLine();
            int money = Integer.parseInt(scanner.nextLine());

            String[] split = line.split(",");
            int [] sums = new int[split.length];
            for (int i = 0; i < split.length; i++) {
                sums[i] = Integer.parseInt(split[i]);
            }
            Arrays.sort(sums);
            int flag = -1;
            for (int i = 0; i < sums.length - 2; i++) {
                if(sums[i] + sums[i+1]+sums[i+2] > money){
                    flag = i-1;
                }
            }

            if(flag != -1){
                System.out.println(sums[flag]);
                System.out.println(sums[flag+1]);
                System.out.println(sums[flag+2]);
            }else {
                System.out.println(-1);
            }

        }
    }
}
